package com.zengqingfa.examples.mybatisplus.chain;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Scope("prototype")
public class FilterChain implements StudyPrepareFilter {

    private int pos = 0;

    @Autowired
    private List<StudyPrepareFilter> studyPrepareFilterList;


    @Override
    public boolean doFilter(PreparationList thingList, FilterChain filterChain) {
        // 所有过滤器执行完毕
        if (pos == studyPrepareFilterList.size()) {
            return true;
        }
        return studyPrepareFilterList.get(pos++).doFilter(thingList, filterChain);
    }

}